<template>
  <div>
    <el-tag
      v-for="tag in tags"
      :key="tag[keyField]"
    >
      {{ tag[valueField] }}
    </el-tag>
  </div>
</template>

<script>
export default {
  name: 'IkTableCheckTag',
  props: {
    value: {
      type: String,
      default: ''
    },
    keyField: {
      type: String,
      default: ''
    },
    valueField: {
      type: String,
      default: ''
    },
    options: {
      type: Array,
      default: function() {
        return []
      }
    }
  },
  data() {
    return {
      val: []
    }
  },
  computed: {
    tags() {
      const tagsArray = []
      for (const item in this.options) {
        if (typeof this.value === 'string') {
          // 如果存在
          if (this.value.split(',').indexOf(this.options[item][this.keyField]) !== -1) {
            tagsArray.push(this.options[item])
          }
        }
      }
      return tagsArray
    }
  },
  created() {
  },
  methods: {}
}
</script>

<style lang="scss">
.el-tag {
  margin-left: 10px;
}
</style>
